package com.med.controller;

import com.med.entity.MedicalRecordDO;
import com.med.entity.UserDO;
import com.med.service.IUserService;
import com.med.vo.UserVO;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


/**
 * @BelongsProject: internet-based-healthcare01
 * @BelongsPackage: com.med.controller
 * @Author: WWJ
 * @CreateTime: 2025-08-13 16:54
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RefreshScope
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private IUserService userService;

    //分页查找患者
    @RequestMapping("/list")
    public TableDataInfo listUser(UserVO userVO) {
        System.out.println("====================" + userVO);
        startPage();
        List<UserDO> list = userService.queryUserList(userVO);
        return getDataTable(list);
    }

    //逻辑删除患者
    @RequestMapping("/delete")
    public R<Integer>  deleteUser(Integer userId) {
        R<Integer> i = userService.deleteUser(userId);
        return i;
    }

    //重置患者密码
    @RequestMapping("/reset")
    public R<Integer> resetPassword(Integer userId) {
        R<Integer> i = userService.resetPassword(userId);
        return i;
    }

    //修改患者账户状态
    @RequestMapping("/update")
    public R<Integer> updateUserStatus(Integer userId) {
        R<Integer> i = userService.updateStatus(userId);
        return i;
    }

    //查询患者的就诊记录
    @RequestMapping("/select")
    public TableDataInfo selectUserMedicalRecord(Integer userId) {
        startPage();
        List<MedicalRecordDO> medicalRecordDos = userService.queryMedicalRecordList(userId);
        return getDataTable(medicalRecordDos);
    }
}
